#include<bits/stdc++.h>
const int MAXN = 2e6+5;
int a[MAXN];
bool temp[MAXN];
int t,n;
using namespace std;
int deal(){
    int ans = 0;
    for(int i = 2;i<=n;i++){
        int j = i-1;
        while((temp[j]^temp[i])&(j>0)){
            --j;
        }
        if((j==0)|(a[j]!=a[i]))continue;
        ans+=a[i];
    }
    return ans;
}
int dfs(int i){
    if(i == n){
        temp[i] = true;
        int x =deal();
        temp[i] = false;
        return max(x,deal());
    }
    temp[i] = true;
    int x =dfs(i+1);
    temp[i] = false;
    return max(x,dfs(i+1));
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin >> t;
    for(int i = 0;i<t;++i){
        cin >>n;
        memset(temp,0,MAXN);
        for(int j =1;j<=n;j++){
            cin >> a[j];
        }
        cout << dfs(2) << endl;
    }

}
